using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class user_accountUC : System.Web.UI.UserControl
{
    logistics.Service lg = new logistics.Service();
    
    protected void Page_Load(object sender, EventArgs e)
    {

        if(!IsPostBack){
        string username = Session["user"].ToString();
        DataSet ds = lg.lgUserInfo(username);
       // load info user
        if (ds.Tables["user"].Rows.Count > 0)
        {
            DataRow dr = ds.Tables["user"].Rows[0];
            txtFName.Text = dr["FirstName"].ToString();
            txtLName.Text = dr["LastName"].ToString();
            txtphone.Text = dr["Phone"].ToString();
            txtAddress.Text = dr["Address"].ToString();
        }
            
             

        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string username = Session["user"].ToString();
        if (lg.lgUserUpdate(txtFName.Text, txtLName.Text, txtphone.Text, txtAddress.Text, username) != 0) {
            lblThongbao.Text = "Info updated!";
        }
        else
        {
            lblThongbao.Text = "Error! Cannot update info";
        }

    }
    protected void Button2_Click1(object sender, EventArgs e)
    {
        string username = Session["user"].ToString();
        if (lg.lgUserPassword(username, txtPassword.Text) != 0)
        {
            lblThongbao.Text = "Password has been changed";
        }
        else {
            lblThongbao.Text = "Error! Cannot change password";
        }
    }
}
